package cn.wolfcode.p2p;

import cn.wolfcode.p2p.base.listener.MyRequestListener;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.web.servlet.ServletListenerRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.PropertySource;
import org.springframework.context.annotation.PropertySources;

//作为一个自定义配置类即可
@Configuration
//引入修改的配置文件
@PropertySources({
        @PropertySource("classpath:application-core.properties"),
        @PropertySource("classpath:msg.properties"),
        @PropertySource("classpath:email.properties")
})
//有两个mapper的文件夹了 另外一个mapper文件夹也是需要被扫描到
@MapperScan(basePackages = {"cn.wolfcode.p2p.base.mapper", "cn.wolfcode.p2p.bussness.mapper"})
public class CoreConfig {

    //创建一个监听对象的bean
    @Bean
    public ServletListenerRegistrationBean requestListenerBean(){
        ServletListenerRegistrationBean bean = new ServletListenerRegistrationBean();
        bean.setListener(new MyRequestListener());
        return bean;
    }

    public static void main(String[] args) {
        SpringApplication.run(CoreConfig.class, args);
    }
}
